package com.xps.and.yuntong.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.xps.and.yuntong.Constants;

import org.greenrobot.eventbus.EventBus;


public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

    private static final String TAG = "WXPayEntryActivity";

    private IWXAPI api;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
        api.handleIntent(getIntent(), this);
        Log.e("WXPayEntryActivity","onCreate");
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        api.handleIntent(intent, this);
        Log.e("WXPayEntryActivity","onNewIntent");
    }

    @Override
    public void onReq(BaseReq req) {
        Log.e("WXPayEntryActivity","onReq");
    }

    @Override
    public void onResp(BaseResp resp) {
        if (resp.errCode != 0) {
            Toast.makeText(getApplicationContext(), "支付失败", Toast.LENGTH_SHORT).show();
        }
        finish();
    }

}
